package com.itSiri.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itSiri.mapper.EmpMapper;
import com.itSiri.pojo.Emp;
import com.itSiri.pojo.PageBean;
import com.itSiri.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public void delete(List<Integer> ids) {
     empMapper.delete(ids);
    }

    @Override
    public PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end) {
      //1 设置分页参数
        PageHelper.startPage(page,pageSize);
        //2. 执行查询
        List<Emp> empList=empMapper.list(name,gender,begin,end) ;
        Page<Emp> p=(Page<Emp>)empList;
        //3. 封装成Page Bean对象
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }
}
